package com.kaishengit.test;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.kaishengit.pojo.User;
import com.kaishengit.util.hibernateUtil;

public class test {

	public static void main(String[] args) {
		
		Session session = hibernateUtil.getSession();
		Transaction tran = session.beginTransaction();
		
		
		/*User user = new User();
		user.setUsername("yuzhen");
		user.setPassword("123");
		session.save(user);
		
		
		User user1 = (User) session.get(User.class, 1);
		System.out.println(user1.getUsername());
		
		User user2 = (User) session.get(User.class, 1);
		user2.setPassword("753");
		System.out.println(user2.getUsername());
		

		User user3 = (User) session.get(User.class, 7);
		session.delete(user3);*/
		
		String hql = "from User";
		Query query = session.createQuery(hql);
		List<User> list = query.list();
		for(User user : list){
			System.out.println(user.getUsername());
		}
		

		tran.commit();
	}
}
